import React, { useState, useEffect } from 'react';
import { Button } from 'antd';

interface Geeting {
  name: string;
  firstName: string;
  lastName: string;
}

const HelloHook = (props: Geeting) => {
  const [count, setCount] = useState(0); // 这里设置了初始值就无需定义类型了
  const [text, setText] = useState<string | null>(null);
  const handleClick =() => {
    setCount(count + 1);
  }
  useEffect(() => {
    if (count > 5) {
      setText("请休息一下！！")
    }
  })
  return (
    <div>
      <p> 你点击了 { count } 次 { text } </p>
      <Button onClick={handleClick}> { props.name } </Button>
    </div>
  )


}

HelloHook.defaultProps = {
  name: '',
  firstName: '',
  lastName: ''
}

export default HelloHook;